package com.example.retrofit;

import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import java.io.IOException;
import java.util.List;

/**
 * @author shanchong
 * @date 2019-07-10
 **/
public class RetrofitDemo {

    public static void main(String[] args) {
        final Retrofit build = new Retrofit.Builder()
                .baseUrl("https://api.github.com")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        final GithubService githubService = build.create(GithubService.class);
        final Call<List<Repos>> lovelyesz = githubService.listRepos("lovelyesz");
        try {
            final Response<List<Repos>> execute = lovelyesz.execute();
            final List<Repos> body = execute.body();
            System.out.println(body);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
